class LogonScene extends eui.Component implements  eui.UIComponent {

	public LogonLayer:eui.Group;
	public InputName:eui.EditableText;
	public InputPW:eui.EditableText;
	public BtnLogon:WF.SingleButton;
	public BtnRegist:WF.SingleButton;
	public BtnRemeberPW:eui.Button;
	public ImageRemeberPW:eui.Image;

	public constructor() 
	{
		super();
		this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
	}

	protected partAdded(partName:string,instance:any):void
	{
		super.partAdded(partName,instance);
	}

	protected childrenCreated():void
	{
		super.childrenCreated();

		this.addDragonBones();
	}

	private onAddToStage():void
	{
		this.BtnLogon.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onLogon, this);
	}

	private onLogon():void
	{
		let in_userName = this.InputName.text.trim();
		let in_password = this.InputPW.text.trim();
		if(in_userName == "")
		{
			new Toast("账号不可为空");
			return;
		}
		if(in_password == "")
		{
			new Toast("密码不可为空");
			return;
		}
		
		const logonRegist = ProtoManager.protoBufRoot.lookupType("GameModule.PBLogonRegist");
		let message = logonRegist.create({userName:in_userName, password:in_password});
		let buffer = logonRegist.encode(message).finish();

		let params = HttpManager.getParams(REQ_TYPE_LOGON, buffer + "");

		HttpManager.postHttp(params, this.logonComplete);
	}

	private logonComplete(_event:egret.Event):void
	{
		var request = <egret.HttpRequest>_event.currentTarget;
	}

	private addDragonBones():void
	{
		DragonBonesManager.parseArmatureData("DBLogon");
		let armatureLogon = DragonBonesManager.createArmatrue("ArmatureLogon", "logo");
		armatureLogon.x = 320;
		armatureLogon.y = 130;
		this.addChild(armatureLogon);

		let armatureGirl = DragonBonesManager.createArmatrue("ArmatureLogon", "girl");
		armatureGirl.x = 900;
		armatureGirl.y = 720;
		this.addChild(armatureGirl);
	}
}